
local dirAF ""~/Dropbox/Covid Info Survey/replication_package/""
local dirBZ ""
local dirEF ""
local dirVP ""C:/Users/pezone/AppData/Local/Dropbox/Dropbox/Covid Info Survey/replication_package/""
local dirVPmac ""/Users/vincenzopezone/Dropbox/Covid Info Survey/replication_package/""

cap cd `dirVPmac'
cap cd `dirAF'
cap cd `dirVP'

use data_wave1 if sample_10==1,clear

*******************
***** Table 1 *****
*******************

local controls_all        college retired unemployed employment_loss_hh income_scale health health_conditions  already_infected liberal ///
age_c n_old female married race_black race_asian hispanic own_house stock health_insurance risk_loving discount trust lockdown       

*** Fixed effects are day and headline order dummies
local fe i.date econ_order health_order i.region

*** Geographic controls: cases per capita, deaths per capita and unemployment rate at the country level
local geo_controls cases_pc deaths_pc ur10


local depvar    worried worried_h_e  pc_10 support_sofar

foreach y in `depvar' {

	reg `y' `controls_all' `fe' `geo_controls',r
	est store `y'
	
	estadd ysumm 

}

esttab `depvar' using "./tables/table_1.tex", replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) b(2)  not ///
stats(N r2_a ymean ysd, fmt(%15.0fc %15.2fc %15.2fc %15.2fc) labels("Observations" "Adj. R\(^2\)" "Mean of Dep. Var." "St. Dev. of Dep. Var.")) ///
nogaps keep(`controls_all' `geo_controls') order(`controls_all' `geo_controls')	nomtitle noline






*** Dependent variable: dummy equal to 1 for choosing the pessimistic article in either domain
local depvar  p_h p_e

***We create a local I for each of the four specifications

*** Worried Health - Worried Economy
local worried_h_e worried_h_e

*** Worried Health + Worried Economy
local worried worried

*** 1. Worried sum and difference
local worried_s_d worried worried_h_e


*** 2. The first principal component
local pc pc

*** 3. Lockdown support
local support_sofar support_sofar


*** 4. All key regressors together
local var_all worried worried_h_e pc support_sofar


***n local with the independent variables
local I worried_s_d pc support_sofar var_all

*** This local "calls" the variables in the regressions with the full set of controls
local c1 `controls_all' `fe' `geo_controls' 

*** Variables to show in the table

local toshow worried worried_h_e pc support_sofar


local C empty c1

*******************
***** Table 2 *****
*******************


gen pc=pc_10
label variable pc "PC1"

local X ""

foreach c in `C' {
		
	foreach i in `I' {
		
		reg health_domain ``i'' ``c'',r
		est store `i'_`c'
			
		estadd ysumm 

		local X `X' `i'_`c'
			
	}
		
}
	
esttab `X' using "./tables/table_2.tex", replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) /// 
stats(N r2_a ymean ysd, fmt(%15.0fc %15.2fc %15.2fc %15.2fc) labels("Observations" "Adj. R\(^2\)" "Mean of Dep. Var." "St. Dev. of Dep. Var.")) nogaps ///
keep(`toshow')	nomtitle noline order(`toshow')
	

*******************
***** Table 3 *****
*******************
	
label variable pc "PC1"

local X ""

local C c1

		
foreach y in `depvar' {
							
		foreach i in `I' {
			
			reg `y' ``i'' `h'  `c1',r
			est store `y'_`i'
				
			estadd ysumm
				
			local X `X' `y'_`i'
			
		}
		
	
	
	esttab `X' using "./tables/table_3.tex", replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) ///
	b(2) se(2) stats(N r2_a ymean ysd, fmt(%15.0fc %15.2fc %15.2fc %15.2fc) labels("Observations" "Adj. R\(^2\)" "Mean of Dep. Var." "St. Dev. of Dep. Var.")) ///
	nogaps keep(`toshow' )	nomtitle noline order(`toshow' )

}




*******************
***** Table 4 *****
*******************

local D 100 0

local prior p_ue  p_deaths p_inf

local X ""

foreach d in `D' {
	

		foreach p in `prior' {
			
			*** These lines make sure that for a given outcome variable its prior level is always included in the regression to control for mean reversion
			if "`p'"=="p_ue" {
				
				local h prob_ue_20_100 prob_ue_20_0
					
			}
			
			else if "`p'"=="p_deaths" {
				
				local h prob_deaths_200_100 prob_deaths_200_0
					
			}
				
			else if "`p'"=="ue" {
				
				local h ue_0 ue_100
					
			}
				
			else if "`p'"=="p_inf" {
				
				local h inf_0 inf_100
					
			}
			
			else {
				
				local h ""
		
			}
			
			reg `p'_rev   pref_seen   pess pess_pref  `p'_prior   `c1'  `h'  if    health_domain==`d',r
			est store   `p'_`d'
				
			estadd ysumm
				
			local X `X' `p'_`d'
				
		}
			
	

}
	
esttab `X' using ./tables/table_4.tex, replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) ///
b(2) se(2) stats(N r2_a ymean ysd, fmt(%15.0fc %15.2fc %15.2fc %15.2fc) labels("Observations" "Adj. R\(^2\)" "Mean of Dep. Var." "St. Dev. of Dep. Var.")) nogaps ///
keep(pref_seen   pess pess_pref  )	nomtitle noline order( pref_seen   pess pess_pref )


*******************
***** Table 5 *****
*******************


gen headline_100=headline_ok*100

local depvar  informativeness reliability  headline_100  money_spent
	
local X ""

	
foreach y in `depvar' {
		
	reg `y'    pref_seen    PE  PH health_domain  `c1',r
	est store   `y'
	
	estadd ysumm
			
	local X `X' `y'
	
}	
			


esttab `X' using ./tables/table_5.tex, replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
stats(N r2_a ymean ysd, fmt(%15.0fc %15.2fc %15.2fc %15.2fc) labels("Observations" "Adj. R\(^2\)" "Mean of Dep. Var." "St. Dev. of Dep. Var.")) ///
nogaps keep(pref_seen)	nomtitle noline order(pref_seen)



*******************
***** Table 6 *****
*******************

local depvar support donation_who

local X ""

foreach d in `D' {
	
	foreach y in `depvar' {

		reg `y'   pref_seen   pess pess_pref i.support_sofar p_inf_prior p_ue_prior p_deaths_prior `c1'   if health_domain==`d',r
		est store   `y'_`d'
	
		estadd ysumm
				
		local X `X'  `y'_`d'
		
	}

}
		
esttab `X' using ./tables/table_6.tex, replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) ///
b(2) se(2) stats(N r2_a ymean ysd, fmt(%15.0fc %15.2fc %15.2fc %15.2fc) labels("Observations" "Adj. R\(^2\)" "Mean of Dep. Var." "St. Dev. of Dep. Var.")) nogaps ///
keep(pref_seen   pess pess_pref)	nomtitle noline order( pref_seen   pess pess_pref )
	

	

use data_wave2 if sample_10==1,clear

gen pc=pc_10

******************
**** Table 7 *****
******************

label variable pc "PC1"

local X ""

local controls_all     college retired unemployed employment_loss_hh income_scale health health_conditions  already_infected  ///
age_c n_old female married race_black race_asian hispanic own_house stock health_insurance risk_loving discount trust lockdown       

*** Fixed effects are day and headline order dummies
local fe i.date   i.region

*** Geographic controls: cases per capita, deaths per capita and unemployment rate at the country level
local geo_controls cases_pc deaths_pc ur10

local c1 `controls_all' `fe' `geo_controls' 


local C empty c1


*** 1. Worried sum and difference
local worried_s_d worried worried_h_e


*** 2. The first principal component
local pc pc

*** 3. Lockdown support
local support_sofar support_sofar


*** 4. All key regressors together
local var_all worried worried_h_e pc support_sofar



local I worried_s_d pc support_sofar var_all


local C  c1

local indepvar worried pc support_sofar

local X ""
	

	
foreach i in `indepvar' {

	reg pessimistic `i' `i'_revealed revealed  `c1',r
	est store a_`i'
			
	lincom `i'+`i'_revealed
			
	estadd scalar s=`r(estimate)'
	estadd scalar s2=`r(se)'
		
	qui sum pessimistic  
	estadd scalar m=`r(mean)'
		
	local X `X' a_`i'
		
}
		
foreach i in `indepvar' {
	
	reg pessimistic `i' `i'_revealed revealed lib_rev_bef  `c1' lib ,r
	est store b_`i'
			
	lincom `i'+`i'_revealed
			
	estadd scalar s=`r(estimate)'
	estadd scalar s2=`r(se)'
		
	qui sum pessimistic 
	estadd scalar m=`r(mean)'

	local X `X' b_`i'
		
}
		
	

esttab `X' using "./tables/table_7.tex", replace label booktabs nonum collabels(none) nogaps  noobs f star(* 0.10 ** 0.05 *** 0.01) ///
b(2) se(2) stats(s s2 N r2 m, fmt(%15.2fc %15.2fc  %15.0fc %15.2fc %15.2fc) labels("Net Effect" "Std. Err." "Observations" "R\(^2\)" "Mean of Dep. Var.")) nogaps ///
keep( worried worried_revealed pc  pc_revealed support_sofar support_sofar_revealed revealed lib_rev_bef lib )	nomtitle noline ///
order(worried worried_revealed pc  pc_revealed support_sofar support_sofar_revealed revealed lib_rev_bef lib  )





